module config

import os
import json

pub struct Win {
pub:
	icon   string
	title  string
	width  int
	height int
	hint   string
	debug  bool
}

pub struct Runtime{
pub:
	address               string
	port                  u16
	start_command         string
	stop_command          string
}

pub struct Config {
pub:
	windows Win
	runtime Runtime
}

// 读取配置文件
pub fn data() Config {
	mut config := Config{}
	mut file := os.read_file("./config.json") or { 
		panic('failed to read the file: ${err}')
	}
	config = json.decode(Config, file) or { 
		panic("config.json decode error:${err}")
	}
	return config
}